import request from "@/utils/request";

/**
 * 可领取优惠券列表
 * http://192.168.88.247:4999/web/#/105/1914
 */
export function getLimitObtainCoupons (params:any, needRunHeaders?: boolean) {
  return request({
    url: "/api/v1/coupon/list",
    method: "get",
    params,
    needRunHeaders: needRunHeaders ?? true
  });
}

/**
 * 已领取的优惠券列表
 * http://192.168.88.247:4999/web/#/105/1916
 */
export function getMyCoupons (params: any, needRunHeaders?: boolean) {
  return request({
    url: "/api/v1/coupon/draw_list",
    method: "get",
    params,
    needRunHeaders: needRunHeaders ?? true
  });
}

/**
 * 领取优惠券
 * http://192.168.88.247:4999/web/#/105/1915
 */
export function obtainCoupon (data: any) {
  return request({
    url: "/api/v1/coupon/draw",
    method: "post",
    data
  });
}

/**
 * 获取权益包关联可用的优惠券
 * http://192.168.88.247:4999/web/#/105/1917
 */
export function getUsageList (params: any, needRunHeaders: boolean) {
  return request({
    url: "/api/v1/coupon/usage_list",
    method: "get",
    params,
    needRunHeaders: needRunHeaders ?? false
  });
}

/**
 * 用户批量领取优惠券
 * http://192.168.88.247:4999/web/#/105/2132
 */
export function multDrawCoupon (data: any) {
  return request({
    url: "/api/v1/coupon/multi_draw",
    method: "post",
    data
  });
}

/**
 * 获取优惠券详情
 * http://192.168.88.247:4999/web/#/105/2643
 */
export function getMyCouponDetail (params: any) {
  return request({
    url: "/api/v1/coupon/coupon_detail",
    method: "get",
    params
  });
}

/**
 * 检测用户是否有资格领取优惠券
 * http://192.168.88.247:4999/web/#/105/2633
 */
export function checkDrawCoupon(data: any, noMsg: boolean) {
  return request({
    noMsg: noMsg ?? true,
    url: "/api/v1/coupon/check_can_draw",
    method: "post",
    data
  });
}
